/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator;

import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
import com.inspur.edp.caf.generator.property.ClassPropertyGenerator;
import com.inspur.edp.cef.api.attr.I18nResourceAttribute;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.method.CreateDataCoreGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.method.CreateDataTypeGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.method.ValueObjGetRepositoryMethodGenerator;

public abstract class ValueObjManagerGenerator extends DataManagerImplGenerator {

  protected ValueObjManagerGenerator(ManagerGeneratorContext parContext) {
    super(parContext);
  }

  @Override
  protected void addExtendMethodGenerator(java.util.ArrayList<ClassMethodGenerator> generators) {
    super.addExtendMethodGenerator(generators);
    generators.add(new CreateDataCoreGenerator(ParentContext));
//    //国际化-判断设计时已生成ValueObjInfo标签，运行时生成国际化相关
//    if (isGenerateI18n() && ParentContext.getProjContext().getI18nModelInfoType() != null) {
//      generators.add(getValueObjResInfosGeneratorMethodGenerator());
//    }
  }

  @Override
  protected java.util.ArrayList<ClassPropertyGenerator> createPropertyGenerators() {

    java.util.ArrayList<ClassPropertyGenerator> list = super.createPropertyGenerators();
    if (list == null) {
      list = new java.util.ArrayList<ClassPropertyGenerator>();
    }
//		list.add(CreateValueObjRepoPropertyGenerator());
    return list;
  }

  protected ValueObjGetRepositoryMethodGenerator createValueObjRepoPropertyGenerator() {
    return new ValueObjGetRepositoryMethodGenerator(ParentContext.getProjContext());
  }

  @Override
  protected Boolean hasDataTypeGenerator() {
    return false;
  }

  @Override
  protected final CreateDataTypeGenerator getDataTypeGenerator() {
    throw new UnsupportedOperationException();
  }

  @Override
  protected void afterGenerate() {
    super.afterGenerate();
  }

  @Override
  protected java.util.ArrayList<BaseGenerator> createClassExtendChildGenrators() {
    java.util.ArrayList<BaseGenerator> list = super.createClassExtendChildGenrators();
    if (list == null) {
      list = new java.util.ArrayList<BaseGenerator>();
    }
    if (isGenerateI18n()) {
      //i18n
      addModelResourceInfoGenenerator(list);
    }
    return list;
  }

  /**
   * 是否生成运行时国际化内容，udt生成，变量不生成
   */
  protected boolean isGenerateI18n() {
    return false;
  }

  private void addModelResourceInfoGenenerator(java.util.ArrayList<BaseGenerator> list) {
//    //读取标签
//    I18nResourceAttribute modelResInfoAttr = ParentContext.getProjContext().getI18nModelInfoType();
//    if (modelResInfoAttr == null) {
//      return;
//    }
//    list.add(
//        new ValueObjModelResourceInfoGenerator(modelResInfoAttr.resourceInfoType(), ParentContext));
  }

//  private final GetValueObjInfosGenerator getValueObjResInfosGeneratorMethodGenerator() {
//    return new GetValueObjInfosGenerator(ParentContext);
//  }
}
